
#include "net.h"
#include <stdlib.h>
#include <errno.h>
#define MAXLEN1 128
//服务器
void server(int readfd, int writefd )
{

	int ret;
	char buf[MAXLEN1];

	while(1)
	{
		bzero(buf, MAXLEN1);
		fgets(buf, MAXLEN1 -1, stdin);	
		write(writefd, buf, strlen(buf));


		//读取数据
		bzero(buf, MAXLEN1);
		do
		{
			ret = read(readfd, buf, MAXLEN1 -1);
		}while(ret < 0 && errno == EINTR );
		if(ret < 0)
		{
			perror("read fail");
			exit(0);
		}
		if(!ret)
		{
			continue;	
		}
		printf("客户端：%s\n", buf );


	}

	
}
